package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.utils.RabbitMqutils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * 死信队列  生产者
 */
public class Producer {

    //普通交换机 名称
    public static final String NORMAL_EXCHANGE="normal_exchange";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqutils.getChannel();
       //死信消息 设置TTl  单位是ms 100000ms=10s  过期时间
//        AMQP.BasicProperties basicProperties =
//                new AMQP.BasicProperties()
//                        .builder().expiration("1000").build();

        for (int i = 1; i < 11; i++) {
            String message="info"+i;
            channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",null,message.getBytes());
          //  channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",basicProperties,message.getBytes());
            System.out.println("生产者发送消息"+message);
        }





    }

}
